#ifndef PERCEPTION_ROS2_DRIVER__NODE_HPP_
#define PERCEPTION_ROS2_DRIVER__NODE_HPP_

#include <rclcpp/rclcpp.hpp>
#include <sensor_msgs/msg/point_cloud2.hpp>

#include <pcl/point_types.h>
#include <pcl_conversions/pcl_conversions.h>
#include <cpprest/http_client.h>

#include "perception_ros2_driver/msg/status.hpp"
#include "perception_ros2_driver/msg/target.hpp"
#include "perception_ros2_driver/msg/targets.hpp"

#include <sys/time.h>
#include <unistd.h>
#include <memory>
#include <vector>
#include <thread>

#include "detection.pb.h"

using namespace web::http;
using namespace web::http::client;

class PerceptionDriverNode : public rclcpp::Node
{
private:
  rclcpp::Publisher<sensor_msgs::msg::PointCloud2>::SharedPtr pointcloud_pub_;
  rclcpp::Publisher<perception_ros2_driver::msg::Targets>::SharedPtr target_pub_;
  rclcpp::Publisher<perception_ros2_driver::msg::Status>::SharedPtr status_pub_;
  rclcpp::TimerBase::SharedPtr status_timer_;

  std::unique_ptr<http_client> client_;
  std::unique_ptr<std::thread> recv_thread_;
  std::string lidar_ip_;

  void runRecvLoop();
  void runStatusReport();
public:
  PerceptionDriverNode();
  ~PerceptionDriverNode() {}
};

#endif  // PERCEPTION_ROS2_DRIVER__NODE_HPP_
